<div class="layui-fluid" id="VIEW-list-table" lay-title="已付款订单">
    <div class="layui-row layui-col-space12">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form" action="" lay-filter="form-group">
                        <div class="layui-form-item">
                            <label class="layui-form-label" >会员：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="memberName" autocomplete="off" placeholder="请输入会员" class="layui-input">
                            </div>
                            <label class="layui-form-label" >订单号：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="orderNumber" autocomplete="off" placeholder="请输入订单号" class="layui-input">
                            </div>

                            <a class="layui-btn search_btn" data-type="getInfo" style="margin-left: 15px;">查询</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <table id="list-table-aftersalesorder" lay-filter="list-table-aftersalesorder"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['admin', 'table', 'form', 'jquery','view'], function () {
        var $ = layui.jquery
            , layer = layui.layer
            , form = layui.form
            , view = layui.view
            , admin = layui.admin
            , table = layui.table;
        var viewList = $('#VIEW-list-table');

        var tableFilter = 'list-table-aftersalesorder';

        table.render({
            elem: '[lay-filter="' + tableFilter + '"]',
            url: '/order/page?token=' + admin.loginToken,
            where :{status:"4"},
            height: 'full-165',
            cols: [[
                {title: '', type: 'checkbox', fixed: true, width: 60},
                {title: '会员', field: 'memberName'},

                {title: '订单号', field: 'orderNumber'},
                {title: '金额', field: 'payment'},
                {
                    title: '状态', width: 80, templet: function (d) {
                    var status = {
                        1: {title: '未付款', color: 'blue'},
                        2: {title: '已付款', color: 'orange'},
                        3: {title: '已发货', color: 'blue'},
                        4: {title: '退货', color: 'orange'}
                    }[d.status];
                    return '<span class="layui-badge layui-bg-' + status.color + '">' + status.title + '</span>';
                }
                },
                {title: '付款时间', field: 'time', align: 'center', minWidth: 250, templet: function (d) {
                    var paymentTime = layui.util.toDateString(d.paymentTime, 'yyyy-MM-dd')
                    return '<p><span title="' + d.paymentTime + '" class="nepadmin-c-gray">' + paymentTime + '</span></p>';
                }
                },
                {title: '操作', width: 220, align: 'center', templet: function (d) {
                    var editBtn = '<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">编辑</a>';
                    var delBtn = '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
                    return editBtn + delBtn;
                }
                }
            ]]
        });

        viewList.find('.search_btn').on("click",function(){
            // 查询
            table.reload("list-table-paidorder",{
                url: '/order/page?token=' + admin.loginToken,
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    status:"4",
                    memberName:$("input[name=memberName]").val(),
                    orderNumber:$("input[name=orderNumber]").val()
                }
            })
        });

        table.on('tool(' + tableFilter + ')', function (obj) {
            if (obj.event === 'del') {//删除行

            } else if (obj.event === "edit") {
                admin.popup({
                    url: '/shop/order/paidOrderShow',
                    area: ['850px', '450px'],
                    data : {
                        table:table,
                        id : obj.data.id
                    }
                });
                return false
            }
        });
    })
</script>